//
//  CameraDetailListCell.m
//  Runone
//
//  Created by runone01 on 16/8/11.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "CameraGunDetailListCell.h"
#import "CameraGunDetailModel.h"
#import "MJExtension.h"
#import "UIImageView+WebCache.h"
@interface CameraGunDetailListCell()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UIView *lineView;

@end
@implementation CameraGunDetailListCell{
    
}
-(instancetype)initWithFrame:(CGRect)frame {
    self=[super initWithFrame:frame];
    if (self) {
//        self.iconImageView.layer.cornerRadius = 7;
        _lineView.layer.cornerRadius  = 2;
        _lineView.layer.masksToBounds = YES;
    }
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    _lineView.layer.cornerRadius  = 2;
    _lineView.layer.masksToBounds = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setCellData:(NSString *)data{
    
    [self.iconImageView sd_setImageWithURL:[data mj_url]];
    
    NSLog(@"%@",[data mj_url]);

}

- (NSString *)componentsSeparatedByString:(NSString *)path{
    NSArray *result = [path componentsSeparatedByString:@"\\"];
    NSString *str=[result lastObject];
    [self timeLabelString:str];
    path = nil;
    for (NSString *obj in result) {
        if (path == nil) {
            path = obj;
        }else{
            path = [NSString stringWithFormat:@"%@/%@",path,obj];
        }
    }
    return path;
}

-(void)timeLabelString:(NSString *)string {
    NSString *year   = [string substringWithRange:NSMakeRange(0, 4)];
    NSString *mone   = [string substringWithRange:NSMakeRange(4, 2)];
    NSString *day    = [string substringWithRange:NSMakeRange(6, 2)];
    NSString *house  = [string substringWithRange:NSMakeRange(8, 2)];
    NSString *min    = [string substringWithRange:NSMakeRange(10, 2)];
    NSString *second = [string substringWithRange:NSMakeRange(12, 2)];
    NSString *time   = [NSString stringWithFormat:@"%@-%@-%@  %@:%@:%@",year,mone,day,house,min,second];
    _timeLabel.text  = time;
}
@end
